import re
from urllib.parse import unquote


def process_url(url):
    # 定义正则表达式，匹配问号前后的内容
    pattern = r'^(.*?)\?(.*)$'
    match = re.match(pattern, url)

    if not match:
        return "URL中未包含问号"

    # 提取问号前后的内容
    before_question = match.group(1)  # 问号前面的部分
    after_question_encoded = match.group(2)  # 问号后面的编码内容

    # 对问号后面的内容进行URL解码（还原为原始模样）
    after_question_decoded = unquote(after_question_encoded)

    return {
        "问号前内容": before_question,
        "问号后原始编码内容": after_question_encoded,
        "问号后解码内容": after_question_decoded
    }


# 测试示例（使用你提供的URL）
url = "https://us-xpc5-l2.xpccdn.com/a951adea-71aa-40b6-bc9e-94b805b95bd9/533dfd83-8112-4469-96f5-50872dd28003.mp4?j=%7B%22userId%22%3A0%2C%22deviceId%22%3A%2234m0k1f3pvmdebzwmv%22%2C%22ip%22%3A%22123.160.225.184%2C1.194.253.55%22%7D"
result = process_url(url)
# 打印结果
print("处理结果：")
for key, value in result.items():
    print(f"{key}：\n{value}\n")
"""


"""